#!/usr/bin/env python
# coding: utf8

class A:
    def __init__(self):
        print('class A', type(self))

class B(A):
    def __init__(self):
        super().__init__()
        print('class B', type(self))

def is_su_shu(b):
    return lambda n: n % b > 0

def nums():
    n = 3
    while True:
        yield n
        n += 2

def sushu(max):
    yield 2
    g = nums()
    b = next(g)
    while b <= max:
        yield b
        g = filter(is_su_shu(b),g)
        b = next(g)

#--------------------
def _odd_iter():
    n = 1
    while True:
        n = n + 2
        yield n

def _not_divisible(n):
    return lambda x: x % n > 0

def primes():
    yield 2
    it = _odd_iter() # 初始序列
    while True:
        n = next(it) # 返回序列的第一个数
        yield n
        it = filter(_not_divisible(n), it) # 构造新序列

def reverse_same(num):
    n1 = num
    n2 = 0
    while num > 0:
        n2 = n2 * 10 + num % 10
        num = num // 10
    return n1 == n2

def lazy_sum(args):
    def sum():
        s = 0
        for i in args:
            s += i
        return s
    return args, sum

def count():
    fs = []
    for i in range(1, 4):
        def f(i):
             return i*i
        fs.append(f)
    return fs

class Chain(object):

    def __init__(self, path=''):
        self._path = path

    def __getattr__(self, path):
        return Chain('%s/%s' % (self._path, path))

    def __str__(self):
        return self._path

    __call__ = __getattr__

    __repr__ = __str__

from enum import Enum

Month = Enum('Month', ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'))

if __name__ == "__main__":
    # class A <class '__main__.B'>
    # class B <class '__main__.B'>
    # B()
    # for i in sushu(100):
    #     print(i)
    # print("*"*100)
    # for n in primes():
    #     if n < 100:
    #         print(n)
    #     else:
    #         break
    # print(list(filter(reverse_same, range(1,1000))))
    # args, sum = lazy_sum([1,2])
    # print(sum())
    # args.append(3)
    # print(sum())
    # f1,f2,f3 = count()
    # print(f1(4))
    print(Chain().user('gateray').repo.list)
    for name, member in Month.__members__.items():
        print(name, '=>', member, ',', member.value)
    with open('main.py', 'r') as f:
        from io import StringIO
        sb = StringIO()
        while True:
            b = f.read(1)
            if not b:
                break
            sb.write(b)
        print(sb.getvalue())

